#ifndef DISPLAY_H
#define DISPLAY_H

#include "sys.h"

enum
{
	OSD1,
	OSD2,
	OSD3
};
#define LCD_SET_MAIN	0X0000
#define LCD_SET_SUB		0X0001
#define LCD_SET_BOTH	0X0002




typedef UINT16 RES_ID_T;

typedef enum
{
	RES_TYPE_MENU,
	RES_TYPE_STRING,
	RES_TYPE_BMP,
	RES_TYPE_GIF,
	RES_TYPE_INVALID
} RES_TYPE_T;


typedef UINT8 	DSP_RET_T;		

typedef enum
{
	OSD_MODE_NORMAL,
	OSD_MODE_KEEN_BLACK
}OSD_MODE_T;


#define LCD_WIDTH	176
#define LCD_HEIGHT	220
//#define LCD_WIDTH	128
//#define LCD_HEIGHT	160

extern UINT16 lcd_buf[LCD_WIDTH][LCD_HEIGHT];
extern UINT16 osd_buf[LCD_WIDTH][LCD_HEIGHT];

#define MAX_OSD_NUM	4

/* Color value constant define begin */
#define COLOR_LCD				0xffff
#define COLOR_BLACK				0x0000
#define COLOR_WHITE			0xffff
#define COLOR_TRANSPANT		0xffdf
#define COLOR_RED				0xf800
#define COLOR_GREEN				0x07e0
#define COLOR_BLUE				0x001f
#define COLOR_YELLOW			0xffe0
#define COLOR_MAGENTA			0xf81f
#define COLOR_CYAN				0x07ff
#define COLOR_AQUAMARINE		0x76d2 
#define COLOR_BRONZE			0x8bca 
#define COLOR_COPPER			0xbb86 
#define COLOR_FELDSPAR			0xd48e 
#define COLOR_GOLD				0xcbe6
#define COLOR_GRAY				0xffde 
#define COLOR_KHAKI				0x9cf3
#define COLOR_MAROON			0x890d 
#define COLOR_ORANGE			0xfbe0 
#define COLOR_ORCHID			0xdb9b 
#define COLOR_PINK				0xbc71 
#define COLOR_PLUM				0xed7d 
#define COLOR_QUARTZ			0xdede 
#define COLOR_SALMON			0x6a08 
#define COLOR_SCARLET			0x88a2 
#define COLOR_SILVER			0xffde 
#define COLOR_THISTLE			0xddfb 
#define COLOR_TURQUOISE			0xaf5d 
#define COLOR_VIOLET			0x4969 
#define COLOR_WHEAT				0x8c5e
#define COLOR_ALICEBLUE			0xf7df 
#define COLOR_ANTIQUEWHITE		0xff5a
#define COLOR_AZURE				0xf7ff 
#define COLOR_BEIGE				0xf7bb 
#define COLOR_BISQUE			0xff38 
#define COLOR_BLANCHEDALMOND	0xff59 
#define COLOR_BLUEVIOLET		0x895c 
#define COLOR_BROWN				0xa145 
#define COLOR_BURLYWOOD			0xddd0 
#define COLOR_CADETBLUE			0x5cf4 
#define COLOR_CHARTREUSE		0x7f80 
#define COLOR_CHOCOLATE			0xd343 
#define COLOR_CORAL				0xfbea 
#define COLOR_CORNFLOWERBLUE 	0x64bd 
#define COLOR_CORNSILK			0xffdb 
#define COLOR_CRIMSON			0xd8a7 
#define COLOR_DARKBLUE			0x0011 
#define COLOR_DARKCYAN			0x0451 
#define COLOR_DARKGOLDENROD 	0xbc21 
#define COLOR_DARKGRAY			0x8410 
#define COLOR_DARKGREEN			0x0320 
#define COLOR_DARKKHAKI			0xbdad 
#define COLOR_DARKMAGENTA		0x8811 
#define COLOR_DARKOLIVEGREEN 	0x5345 
#define COLOR_DARKORANGE		0xfc60 
#define COLOR_DARKORCHID		0x9999 
#define COLOR_DARKRED			0x8800 
#define COLOR_DARKSALMON		0xecaf 
#define COLOR_DARKSEAGREEN		0x8df1 
#define COLOR_DARKSLATEBLUE 	0x49f1
#define COLOR_DARKSLATEGRAY		0x2a69 
#define COLOR_DARKTURQUOISE		0x067a 
#define COLOR_DARKVIOLET		0x901a 
#define COLOR_DEEPPINK			0xf8b2 
#define COLOR_DEEPSKYBLUE		0x05ff 
#define COLOR_DIMGRAY			0x6b4d 
#define COLOR_DODGERBLUE		0x1c9f 
#define COLOR_FIREBRICK			0xb104 
#define COLOR_FIORALWHITE		0xffde
/* Color value constant define begin */

typedef UINT16	COLOR_T;

typedef enum
{
	ALIGN_DEFAULT,
	ALIGN_LEFT,
	ALIGN_MID,
	ALIGN_RIGHT
}ALIGN_TYPE_T;


typedef enum
{
	FONT_7_5,
	FONT_12_12,
	FONT_16_16
}FONT_TYPE_T;


typedef struct 
{
	UINT16 		x_pos;		// X coordinate of the point
	UINT16 		y_pos;		// Y coordinate of the point
	COLOR_T 	clr;		// Color value of the point need to be set
}POINT_T;

typedef struct
{
	UINT16 		x_start;	// line start position x
	UINT16 		y_start;	// line start position y
	UINT16 		x_end;		// line end position x
	UINT16 		y_end;		// line end position y
	COLOR_T 	clr;		// line color
}LINE_T;

typedef struct
{
	UINT16		x_pos;		// start position x of the rectangle 
	UINT16		y_pos;		// start postion y of the rectangle 
	UINT16		width;		// width of the rectangle
	UINT16		height;		// height of the rectangle
	COLOR_T		clr_line;	// the line color of the rcectangle
	COLOR_T		clr_fill;	// the filled color of the rectangle 
}RECT_T;
typedef struct osd
{
	UINT8	 is_visible;	// is this osd need display?
	UINT8	 alpha_value;	// alpha value of the osd
	RECT_T	 rect;			// osd rectangle in buffer
}OSD_T;
	
extern UINT8 g_lang;

UINT32		dsp_rgb(UINT8 clr_r,UINT8 clr_g,UINT8 clr_b);

extern void     dsp_initialize (void);
extern void 	dsp_draw_point(POINT_T *p_point);
extern void 	dsp_draw_line(LINE_T *p_line);
extern void 	dsp_draw_rect(RECT_T *p_rect);
extern UINT8	dsp_strlen(UINT16* str,FONT_TYPE_T font_type);
extern UINT32 dsp_convert_565_to_888(UINT16 data);
extern void	dsp_draw_button(RECT_T *p_rect);
extern void	dsp_update_win(RECT_T* p_rect);
extern void	dsp_update_screen(void);
extern void	dsp_clean_win(RECT_T* p_rect);
extern void	dsp_draw_reverse_rect(RECT_T *p_rect);
extern void	dsp_draw_unicode(POINT_T *p_point,const UINT16 uincode,FONT_TYPE_T font_type);
extern void     dsp_draw_unicode_with_rim(POINT_T *p_point,const UINT16 uincode,FONT_TYPE_T font_type,COLOR_T rim_color);
extern void 	dsp_draw_unicode_two_color(POINT_T *p_point,const UINT16 uincode,UINT8 start_x,UINT16 new_color,FONT_TYPE_T font_type);

extern void	dsp_draw_string(POINT_T *p_point,const UINT16* p_uincode,FONT_TYPE_T font_type);
extern void     dsp_draw_string_with_rim(POINT_T *p_point,const UINT16* p_uincode,FONT_TYPE_T font_type,COLOR_T rim_color);
extern void	dsp_draw_string_by_id(POINT_T *p_point, RES_ID_T res_id,FONT_TYPE_T font_type);
extern void	dsp_draw_string_with_align(RECT_T* p_rect,UINT16* p_unicode,FONT_TYPE_T font_type,ALIGN_TYPE_T align_type);
extern void	dsp_draw_string_with_align_by_id(RECT_T* p_rect,RES_ID_T res_id,FONT_TYPE_T font_type,ALIGN_TYPE_T align_type);
extern void	dsp_draw_bmp_by_buf(RECT_T *p_rect, const UINT16* p_buffer);
extern void	dsp_draw_bmp_by_id(POINT_T *p_point,RES_ID_T res_id);
extern void dsp_draw_transpant_bmp_by_id(POINT_T *p_point,RES_ID_T res_id);
extern void	dsp_draw_string_in_rect(RECT_T* p_rect,const UINT16* p_unicode,FONT_TYPE_T font_type);
extern void dsp_draw_string_in_rect_two_color(
	RECT_T* p_rect,
	const UINT16* p_unicode,
	UINT8 old_start_pos,
	UINT8 old_start_pixel,
	FONT_TYPE_T font_type
);
extern void	dsp_redraw_part_of_bmp_by_id(POINT_T* p_origin_bmp_pt,RECT_T* p_offset_bmp_rect,RES_ID_T res_id);
extern void	dsp_osd_display(UINT8 osd_id,RECT_T* p_rect,UINT16* p_buf,UINT8 alpha_value,OSD_MODE_T osd_mode);
extern void	dsp_osd_update(void);
extern void	dsp_osd_enable(UINT8 osd_id);
extern void	dsp_osd_disable(UINT8 osd_id);


#endif
